<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <!--如果想在工具栏加入更多按钮，可以使用插槽方式， slot = 'left' or 'right'-->
      <crudOperation :permission="permission" />
      <!--表单组件-->
      <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="1000px">
        <el-form ref="form" :model="form" :rules="rules" size="small" label-width="180px">
          <!-- <el-form-item label="pID" prop="pId">
            <el-input v-model="form.pId" style="width: 370px;" />
          </el-form-item> -->
          <el-form-item label="实际随访日期-起始时间">
            <el-date-picker v-model="form.followUpStartDate" type="datetime" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="实际随访日期-起始时间">
            <el-date-picker v-model="form.followUpEndDate" type="datetime" style="width: 370px;" />
          </el-form-item>
          <el-divider />
          <h4>直接医疗成本</h4>
          <el-divider />
          <el-form-item label="MG治疗总费用（元）">
            <el-input v-model="form.mgCost" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="医保类型">
            <el-input v-model="form.medicalInsuranceType" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="是否异地就医">
            <el-radio-group v-model="form.isRemoteMedical">
              <el-radio :label="1">是</el-radio>
              <el-radio :label="2">否</el-radio>
            </el-radio-group>
          </el-form-item>
          <el-form-item label="医保报销比例">
            <el-input v-model="form.edicalInsuranceReimbursementRatio" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="是否有补充医疗保险">
            <el-radio-group v-model="form.isHaveSupplementaryMedicalInsurance">
              <el-radio :label="1">是</el-radio>
              <el-radio :label="2">否</el-radio>
            </el-radio-group>
          </el-form-item>
          <el-form-item label="商业保险类型">
            <el-input v-model="form.businessInsuranceType" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="商业保险报销比例">
            <el-input v-model="form.businessInsuranceReimbursementRatio" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="医保报销费用（元）">
            <el-input v-model="form.edicalInsuranceReimbursementCost" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="自费金额（元）">
            <el-input v-model="form.ownCost" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="MG患者住院起始时间">
            <el-date-picker v-model="form.mgHospitalizationStartDate" type="datetime" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="MG患者住院结束时间">
            <el-date-picker v-model="form.mgHospitalizationEndDate" type="datetime" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="MG患者住院时长（天）">
            <el-input v-model="form.mgHospitalizationDays" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="MG患者住院期间总费用（元）">
            <el-input v-model="form.mgHospitalizationCost" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="院外附加治疗费用（元）">
            <el-input v-model="form.extraHospitalTreatmentCost" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="血液制品和蛋白质制品费用（元）">
            <el-input v-model="form.bloodProductsProteinProductsCost" style="width: 370px;" />
          </el-form-item>
          <el-divider />
          <h4>直接非医疗成本</h4>
          <el-divider />
          <el-form-item label="陪护家属人数">
            <el-input v-model="form.familyMembers" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="乘坐交通工具前往就诊次数">
            <el-input v-model="form.visitsNumberTransportation" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="平均每次人均交通费用（元）">
            <el-input v-model="form.transportationCostAverage" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="总交通费（元）">
            <el-input v-model="form.totalTransportationCost" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="患者院外住宿时长（天）">
            <el-input v-model="form.outOfHospitalAccommodationDays" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="患者院外住宿日均费用（元）">
            <el-input v-model="form.outOfHospitalAccommodationCostAverage" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="患者膳食日均费用（元）">
            <el-input v-model="form.dietCostAverage" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="家属院外住宿时长（天）">
            <el-input v-model="form.familyMembersOutOfHospitalAccommodationDays" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="家属院外住宿日均费用（元）">
            <el-input v-model="form.familyMembersOutOfHospitalAccommodationCostAverage" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="家属膳食日均费用（元）">
            <el-input v-model="form.familyMembersDietCostAverage" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="总食宿费（元）">
            <el-input v-model="form.totalDietCost" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="护理人员人数">
            <el-input v-model="form.paramedicNum" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="总陪护费（非家属）（元）">
            <el-input v-model="form.escortFee" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="直接非医疗成本总费用（元）">
            <el-input v-model="form.nonMedicalCosts" style="width: 370px;" />
          </el-form-item>
          <el-divider />
          <h4>间接成本</h4>
          <el-divider />
          <el-form-item label="患者误工天数">
            <el-input v-model="form.daysLost" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="患者工种">
            <el-input v-model="form.workType" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="患者误工总损失费（元）">
            <el-input v-model="form.lossCost" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="家属误工天数">
            <el-input v-model="form.familyMembersDaysLost" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="家属工种">
            <el-input v-model="form.familyMembersWorkType" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="家属误工总损失费（元）">
            <el-input v-model="form.familyMembersLossCost" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="患者是否因患病更换工种">
            <el-radio-group v-model="form.isChangeWorkType">
              <el-radio :label="1">是</el-radio>
              <el-radio :label="2">否</el-radio>
            </el-radio-group>
          </el-form-item>
          <el-form-item label="患者是否因患病而休学">
            <el-radio-group v-model="form.isSuspension">
              <el-radio :label="1">是</el-radio>
              <el-radio :label="2">否</el-radio>
            </el-radio-group>
          </el-form-item>
          <el-form-item label="患者是否因患病而退休">
            <el-radio-group v-model="form.idRetire">
              <el-radio :label="1">是</el-radio>
              <el-radio :label="2">否</el-radio>
            </el-radio-group>
          </el-form-item>
          <el-form-item label="间接成本总费用（元）">
            <el-input v-model="form.indirectCost" style="width: 370px;" />
          </el-form-item>
          <el-divider />
          <h4>EQ-5D-5L量表</h4>
          <el-divider />
          <el-form-item label="行动能力----我四处活动">
            <el-radio-group v-model="form.eq5d5l1">
              <el-radio :label="1">没有困难</el-radio>
              <el-radio :label="2">有一点困难</el-radio>
              <el-radio :label="3">有中度困难</el-radio>
              <el-radio :label="4">有严重困难</el-radio>
              <el-radio :label="5">我无法四处走动</el-radio>
            </el-radio-group>
          </el-form-item>
          <el-form-item label="自我照顾----我自己洗澡或洗衣">
            <el-radio-group v-model="form.eq5d5l2">
              <el-radio :label="1">没有困难</el-radio>
              <el-radio :label="2">有一点困难</el-radio>
              <el-radio :label="3">有中度困难</el-radio>
              <el-radio :label="4">有严重困难</el-radio>
              <el-radio :label="5">我无法洗澡或洗衣</el-radio>
            </el-radio-group>
          </el-form-item>
          <el-form-item label="日常活动（如工作、学习、家务、家庭或休闲活动）">
            <el-radio-group v-model="form.eq5d5l3">
              <el-radio :label="1">没有困难</el-radio>
              <el-radio :label="2">有一点困难</el-radio>
              <el-radio :label="3">有中度困难</el-radio>
              <el-radio :label="4">有严重困难</el-radio>
              <el-radio :label="5">我无法进行日常活动</el-radio>
            </el-radio-group>
          </el-form-item>
          <el-form-item label="疼痛或不舒服">
            <el-radio-group v-model="form.eq5d5l4">
              <el-radio :label="1">我没有疼痛或不舒服</el-radio>
              <el-radio :label="2">有一点疼痛或不舒服</el-radio>
              <el-radio :label="3">有中度疼痛或不舒服</el-radio>
              <el-radio :label="4">有严重疼痛或不舒服</el-radio>
              <el-radio :label="5">我非常严重的疼痛或不舒服</el-radio>
            </el-radio-group>
          </el-form-item>
          <el-form-item label="焦虑或沮丧">
            <el-radio-group v-model="form.eq5d5l5">
              <el-radio :label="1">我没有焦虑或沮丧</el-radio>
              <el-radio :label="2">有一点焦虑或沮丧</el-radio>
              <el-radio :label="3">有中度焦虑或沮丧</el-radio>
              <el-radio :label="4">有严重焦虑或沮丧</el-radio>
              <el-radio :label="5">我非常严重的焦虑或沮丧</el-radio>
            </el-radio-group>
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="text" @click="crud.cancelCU">取消</el-button>
          <el-button :loading="crud.status.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
        </div>
      </el-dialog>
      <!--表格渲染-->
      <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
        <el-table-column type="selection" width="55" />
        <el-table-column prop="id" label="ID" />
        <!-- <el-table-column prop="pId" label="pID" /> -->
        <el-table-column prop="followUpStartDate" label="实际随访日期-起始时间" />
        <el-table-column prop="followUpEndDate" label="实际随访日期-起始时间" />
        <el-table-column prop="mgCost" label="MG治疗总费用（元）" />
        <el-table-column prop="nonMedicalCosts" label="直接非医疗成本总费用（元）" />
        <el-table-column prop="indirectCost" label="间接成本总费用（元）" />
        <el-table-column v-if="checkPer(['admin','healthEconomics:edit','healthEconomics:del'])" label="操作" width="150px" align="center">
          <template slot-scope="scope">
            <udOperation
              :data="scope.row"
              :permission="permission"
            />
          </template>
        </el-table-column>
      </el-table>
      <!--分页组件-->
      <pagination />
    </div>
  </div>
</template>

<script>
import crudHealthEconomics from '@/api/healthEconomics'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
// import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'

const defaultForm = {
  id: null,
  pId: '',
  followUpStartDate: null,
  followUpEndDate: null,
  mgCost: null,
  medicalInsuranceType: null,
  isRemoteMedical: null,
  edicalInsuranceReimbursementRatio: null,
  isHaveSupplementaryMedicalInsurance: null,
  businessInsuranceType: null,
  businessInsuranceReimbursementRatio: null,
  edicalInsuranceReimbursementCost: null,
  ownCost: null, mgHospitalizationStartDate:
  null, mgHospitalizationEndDate: null,
  mgHospitalizationDays: null,
  mgHospitalizationCost: null,
  extraHospitalTreatmentCost: null,
  bloodProductsProteinProductsCost: null,
  familyMembers: null,
  visitsNumberTransportation: null,
  transportationCostAverage: null,
  totalTransportationCost: null,
  outOfHospitalAccommodationDays: null,
  outOfHospitalAccommodationCostAverage: null,
  dietCostAverage: null,
  familyMembersOutOfHospitalAccommodationDays: null,
  familyMembersOutOfHospitalAccommodationCostAverage: null,
  familyMembersDietCostAverage: null,
  totalDietCost: null,
  paramedicNum: null,
  escortFee: null,
  nonMedicalCosts: null,
  daysLost: null,
  workType: null,
  lossCost: null, familyMembersDaysLost: null, familyMembersWorkType: null, familyMembersLossCost: null, isChangeWorkType: null, isSuspension: null, idRetire: null, indirectCost: null, eq5d5l1: null, eq5d5l2: null, eq5d5l3: null, eq5d5l4: null, eq5d5l5: null }
export default {
  name: 'HealthEconomics',
  components: { pagination, crudOperation, udOperation },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  data() {
    return {
      permission: {
        add: ['admin', 'healthEconomics:add'],
        edit: ['admin', 'healthEconomics:edit'],
        del: ['admin', 'healthEconomics:del']
      },
      rules: {
        pId: [
          { required: true, message: 'pID不能为空', trigger: 'blur' }
        ]
      },
      queryTypeOptions: [
        { key: 'pId', display_name: 'pID' }
      ],
      pId: this._routerRoot._route.query.id
    }
  },
  cruds() {
    return CRUD({ title: '卫生经济学', url: 'api/healthEconomics', query: { 'pId': this.pId }, idField: 'id', sort: 'id,desc', crudMethod: { ...crudHealthEconomics }})
  },
  created() {
    defaultForm.pId = this.pId
    this.crud.query.pId = this.pId
  },
  methods: {
    // 钩子：在获取表格数据之前执行，false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      this.crud.query.pId = this.pId
      return true
    }
  }
}
</script>

<style scoped>

</style>
